<html>
	<head>
		<style>
			body {
				margin: 0px auto;
			}
			table.haho {
				border: 1px solid black;
				font: 14px Arial, Helvetica, sans-serif;
				color: #000;
			}
			table.haho td {
				border: 1px solid black;
			}
			table.haho tr {
				border: 1px solid black;
			}
			table.haho th {
				border: 1px solid black;
			}
			table {
				width: 90%;
			}
			table.kosong {
				border: none;
				font: 29px Arial, Helvetica, sans-serif;
			}
			.title {
				font: 18px Arial, Helvetica, sans-serif;
				color: #03F;
				text-align: center;
				margin-top: 10px;
				margin-bottom: 20px;
			}
			div {
				text-align: justify;
				text-justify: inter-word;
				width: 90%;
				font: 14px Arial, Helvetica, sans-serif
			}

		</style>
	</head>
	<title>Final Report</title>

	<body>

		<table width="90%" border="0" cellspacing="0" cellpadding="0" align="center" class="kosong">
			<tr>
				<td width="50%"><img src="<?php echo base_url()?>assets/img/logoCFIsmall.jpg" width="145" height="100"></td>
				<td align="right"><img src="<?php echo base_url()?>assets/img/logoPerpusSmall.jpg" width="241" height="100"></td>
			</tr>
		</table>
		<p align="left">
			<div class="title">
				IDENTITAS LAPORAN
			</div>

			<!-- Tabel Identitas Laporan-->
			<table border="1" cellpadding="5" cellspacing="0" align="center" class="haho" >
				<tr>
					<td>Provinsi : </td>
					<td colspan="3" style="width:70%"><?php if ($berkas->getPerpustakaan()->getDesa()->getDistrik()->getPropinsi() != null) echo $berkas->getPerpustakaan()->getDesa()->getDistrik()->getPropinsi()->getNama();?>&nbsp;</td>
				</tr>
				<tr>
					<td>Kab/Kota : </td>
					<td colspan="3" style="width:70%"><?php if ($berkas->getPerpustakaan()->getDesa()->getDistrik() != null) echo $berkas->getPerpustakaan()->getDesa()->getDistrik()->getNama();?></td>
				</tr>
				<tr>
					<td>Desa: </td>
					<td colspan="3" style="width:70%"><?php if ($berkas->getPerpustakaan()->getDesa() != null) echo $berkas->getPerpustakaan()->getDesa()->getNama();?></td>
				</tr>
				<tr>
					<td>Nama Perpustakaan : </td>
					<td colspan="3" style="width:70%"><?php if ($berkas->getPerpustakaan() != null) echo $berkas->getPerpustakaan()->getNama();?></td>
				</tr>
				<tr>
					<td>Jenis Laporan : </td>
					<td colspan="3" style="width:70%"><?php echo $berkas->getTipe()->getNama();?></td>
				</tr>
				<tr>
					<td>Rincian Laporan: </td>
					<td colspan="3 style="width:70%""><?php if ($berkasTraining != null) 
															echo $berkasTraining->getJenisTraining()->getNama();
															
													?>&nbsp;</td>
				</tr>
				<?php
			$fromDate = "-";
			$toDate = "-";
			
			if ($berkasTraining != NULL){
				if ($berkasTraining->getFromDate() != NULL){
					$fromDate = $berkasTraining->getFromDate()->format('d-m-Y');
					$toDate = $berkasTraining->getToDate()->format('d-m-Y');	
				} else {
					$fromDate = "-";
					$toDate = "-";
				}
				
			} else if ($berkasLkpm != NULL) {
				if ($berkasLkpm->getFromDate() != NULL){
					$fromDate = $berkasLkpm->getFromDate()->format('d-m-Y');
					$toDate = $berkasLkpm->getToDate()->format('d-m-Y');
				} else {
					$fromDate = "-";
					$toDate = "-";
				}	
			} else if ($berkasLas != NULL){
				if ($berkasLas->getFromDate() != NULL){
					$fromDate = $berkasLas->getFromDate()->format('d-m-Y');
					$toDate = $berkasLas->getToDate()->format('d-m-Y');
				} else {
					$fromDate = "-";
					$toDate = "-";
				}	
			}
			?>
				<tr>
					<td>Tanggal Kegiatan Dimulai : </td>
					<td><?=$fromDate?></td>
					<td>Tanggal Kegiatan Selesai : </td>
					<td><?=$toDate?></td>
				</tr>
			</table>
			<br>

			<?php if ($berkasLkpm != null) { ?>
			<!-- Table Jenis Kegiatan-->
			<table border="1" cellpadding="5" cellspacing="0" align="center" class="haho">
				<tr>
					<td >Jenis Kegiatan : </td>
					<td colspan="2"><?php if ($berkasLkpm != null) echo $berkasLkpm->getJenisKegiatan()->getNama()?>&nbsp; </td>

				</tr>
				<?php 
				  if (is_array($berkasLkpmSasarans) && count($berkasLkpmSasarans) > 0){
					  $i = 0;
					  foreach ($berkasLkpmSasarans as $row){
					  		if ($i = 0){
					  			echo '<td style="width:70%">'.$row->getNama().'</td>
									</tr>';											
					  		}  else {
					  			echo '<tr>
										<td>&#10003;</td>
										<td style="width:70%">Perempuan</td>
									</tr>';		
					  		}
							$i++;
					  }  	
				  }
				?>
		<!--		<tr>
					<td rowspan="7">Kelompok Sasaran : </td>
					<td>&#10003;</td>
					<td style="width:70%">Pemuda</td>
				</tr>
				<tr>
					<td>&#10003;</td>
					<td style="width:70%">Perempuan</td>
				</tr>
				<tr>
					<td>&#10003;</td>
					<td style="width:70%">UKM</td>
				</tr>
				<tr>
					<td>&#10003;</td>
					<td style="width:70%">Anak Anak</td>
				</tr>
				<tr>
					<td>&#10003;</td>
					<td style="width:70%">Umum</td>
				</tr>
				<tr>
					<td>&#10003;</td>
					<td style="width:70%">Pemerintah:  xxxxx</td>
				</tr>
				<tr>
					<td>&#10003;</td>
					<td style="width:70%">Non Pemerintah:  xxxxxx</td>
				</tr>
				<tr>
					<td rowspan="9">Topik Kegiatan : </td>
					<td>&#10003;</td>
					<td style="width:70%">Kesehatan</td>
				</tr>
				<tr>
					<td>&#10003;</td>
					<td style="width:70%">Pendidikan</td>
				</tr>
				<tr>
					<td>&#10003;</td>
					<td style="width:70%">Pembangunan Ekonomi</td>
				</tr>
				<tr>
					<td>&#10003;</td>
					<td style="width:70%">TIK</td>
				</tr>
				<tr>
					<td>&#10003;</td>
					<td style="width:70%">Pertanian</td>
				</tr>
				<tr>
					<td>&#10003;</td>
					<td style="width:70%">Pemerintahan</td>
				</tr>
				<tr>
					<td>&#10003;</td>
					<td style="width:70%">Hobi dan Hiburan</td>
				</tr>
				<tr>
					<td>&#10003;</td>
					<td style="width:70%">Advokasi</td>
				</tr>
				<tr>
					<td>&#10003;</td>
					<td style="width:70%">Kemitraan/Sponsorship</td>
				</tr> -->
			</table>
			<?php } ?>
			<br>

			<!-- Table Jenis Asistensi-->
			<?php if ($berkasLas != null) { ?>
			<table border="1" cellpadding="5" cellspacing="0" align="center" class="haho">
				<tr>
					<td>Jenis Asistensi : </td>
					<td colspan="2"><?php if ($berkasLas != NULL){
															if ($berkasLas->getJenisAsistensi() == 1){
																$jenisAsistensi = "Non Kunjungan";
															} else {
																$jenisAsistensi = "Kunjungan";
															}
															echo $jenisAsistensi;
														}
													?>&nbsp; </td>
				</tr>
				<tr>
					<td rowspan="6">Media Asistensi : </td>
					<td>&#10003;</td>
					<td style="width:70%"><?=$berkasLas->getMedia()->getNama()?></td>
				</tr>
				<!--<tr>
					<td>&#10003;</td>
					<td style="width:70%">Email</td>
				</tr>
				<tr>
					<td>&#10003;</td>
					<td style="width:70%">Telepon/SMS</td>
				</tr>
				<tr>
					<td>&#10003;</td>
					<td style="width:70%">Skype</td>
				</tr>
				<tr>
					<td>&#10003;</td>
					<td style="width:70%">Forum Online</td>
				</tr>
				<tr>
					<td>&#10003;</td>
					<td style="width:70%">Lainnya: xxxxx</td>
				</tr> -->
				<tr>
					<td rowspan="5">Kategori Asistensi : </td>
					<td>&#10003;</td>
					<td style="width:70%"><?=$berkasLas->getKategoriAsistensi()->getNama()?></td>
				</tr>
				<!--<tr>
					<td>&#10003;</td>
					<td style="width:70%">Partisipasi Kegiatan</td>
				</tr>
				<tr>
					<td>&#10003;</td>
					<td style="width:70%">TIK</td>
				</tr>
				<tr>
					<td>&#10003;</td>
					<td style="width:70%">Community Engagement</td>
				</tr>
				<tr>
					<td>&#10003;</td>
					<td style="width:70%">Advokasi dan Kemitraan</td>
				</tr>-->
			</table>
			<?php } ?>
			<br>
		</p>
	<!--	<table width="90%" border="0" cellspacing="0" cellpadding="0" align="center" class="kosong">
	  <tr>
	    <td width="50%"><img src="logoCFIsmall.jpg" width="145" height="100"></td>
	    <td align="right"><img src="logoPerpusSmall.jpg" width="241" height="100"></td>
      </tr>
 </table> -->
	
	<p>
		<?php if ($berkasTraining != null) { ?>
		<div class="title">JUMLAH PESERTA</div>
		<!-- Tabel Jumlah Peserta -->
		<table border="1" cellpadding="5" cellspacing="0" class="haho" align="center"> 
			<tr>
				<td colspan="2">Staf Perpustakaan</td>
				<td colspan="2">Non-Staf Perpustakaan</td>
				<td colspan="3">Total</td>
				<td rowspan="2">Lainnya</td>
			</tr> 
			<tr>
				<td>Laki - Laki</td>
				<td>Perempuan</td>
				<td>Laki - Laki</td>
				<td>Perempuan</td>			
				<td>Laki - Laki</td>
				<td>Perempuan</td>
				<td>Total</td>
			</tr>
			<?php
				$stafLaki = 0;
				$stafPr = 0;
				$nonstafLaki = 0;
				$nonstafPr = 0;
				$lainnya = 0;
				foreach ($memberOfTraining as $row){
					if ($row->getStaff() == "S"){
						if ($row->getGender() == "M"){
							$stafLaki++;
						} else if ($row->getGender()=="F"){
							$stafPr++;
						} 
					} else if ($row->getStaff() == "N") {
						if ($row->getGender() == "M"){
							$nonstafLaki++;
						} else if ($row->getGender()=="F"){
							$nonstafPr++;
						}
					} else {
						$lainnya++;
					}																				
				}  
				
				$laki = $stafLaki + $nonstafLaki;
				$pr = $stafPr + $nonstafPr;
				$total = $laki + $pr;
				if ($stafLaki <= 0){
					$stafLaki = "-";
				}
				
				if ($stafPr <= 0){
					$stafPr = "-";
				}
				
				if ($nonstafLaki <= 0){
					$nonstafLaki = "-";
				}
				
				if ($nonstafPr <= 0){
					$nonstafPr = "-";
				}
				
				if ($laki <= 0){
					$laki = "-";
				}
				
				if ($pr <= 0){
					$pr = "-";
				}
				
				if ($total <= 0){
					$total = "-";
				}
				
				if ($lainnya <= 0){
					$lainnya = "-";
				}
			?>
			<tr>
				<td><?=$stafLaki?></td>
				<td><?=$stafPr?></td>
				<td><?=$nonstafLaki?></td>
				<td><?=$nonstafPr?></td>			
				<td><?=$laki?></td>
				<td><?=$pr?></td>
				<td><?=$total?></td>
				<td><?=$lainnya?></td>
			</tr> 
		</table>
		<br>
		<?php } ?>
		<div class="title">GAMBARAN KEGIATAN</div>
		<div>
		<?php
				echo $berkas->getDescription();
		?></div>
		<br>
		<div class="title">HASIL KEGIATAN</div>
		<div>
		<?php
				echo $berkas->getHasilKegiatan();
		?>	
		</div>
		<br>
		<div class="title">TANTANGAN KEGIATAN</div>
		<div>
		<?php
				echo $berkas->getTantangan();
		?>
		</div>
		<br>
		<div class="title">LAMPIRAN</div>
		<div>
		<ol>
			<?php
				if (is_array($berkasAttachments) && count($berkasAttachments) > 0){
					//die('test');
					foreach ($berkasAttachments as $row){
						echo '<li>'.$row->getPath().'</li>';
					}
				}
				//die();
			?>	
		</ol>  
		</div>
		<br>
		<div class="title">CATATAN TAMBAHAN</div>
		<table border="1" cellpadding="5" cellspacing="0" class="haho" align="center"> 
			<tr>
				<td>Tanggal Laporan Dibuat:</td>
				<td><?php echo $berkas->getStartDate()->format('d-m-Y h:i:s');?></td>
				<td>Tanggal Laporan Dikirimkan:</td>
				<td><?php if ($berkasTerkirim !=NULL) echo $berkasTerkirim['createdDate']?></td>
			</tr> 
			<tr>
				<td>Tanggal Laporan Selesai Direview:</td>
				<td><?php if ($berkasTerkirim !=NULL) echo $berkasTereview['createdDate']?></td>
				<td>Tanggal Laporan Disetujui:</td>
				<td><?php echo $berkas->getEndDate()->format('d-m-Y h:i:s'); ?></td>
			</tr>
		</table>
	</p>
	</body>
</html>